﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesHuanJi.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeReceivablesHuanJi" %>
<%--换机--%>
<script type="text/javascript">

    $(document).ready(function () {

        $("#FTradeReceivablesHuanJi_Price,#FTradeReceivablesHuanJi_GPSFeiYong,#FTradeReceivablesHuanJi_YueCuXiaoJinE").change(function () {
            changeHHeTongJinE()
        })
        function changeHHeTongJinE() {
            //处理合同金额
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesHuanJi_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesHuanJi_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesHuanJi_YueCuXiaoJinE").val());

            $("#FTradeReceivablesHuanJi_HeTongJinE").val((-1) * Price + GPSFeiYong + YueCuXiaoJinE);
        }
        $("#FTradeReceivablesHuanJi_GPSFeiYong").val((-1) * parseFloat($("#FTradeReceivablesHuanJi_GPSFeiYong").val()));
        $("#FTradeReceivablesHuanJi_YueCuXiaoJinE").val((-1) * parseFloat($("#FTradeReceivablesHuanJi_YueCuXiaoJinE").val()))

        changeHHeTongJinE();

        //2.处理换新机后的信息
        //处理合同金额
        $("#FTradeReceivablesHuanJiNew_Price,#FTradeReceivablesHuanJiNew_GPSFeiYong,#FTradeReceivablesHuanJiNew_YueCuXiaoJinE").change(function () {
            if ($(this).val() == "")
                $(this).val(0);
            var Price = parseFloat($("#FTradeReceivablesHuanJiNew_Price").val());
            var GPSFeiYong = parseFloat($("#FTradeReceivablesHuanJiNew_GPSFeiYong").val());
            var YueCuXiaoJinE = parseFloat($("#FTradeReceivablesHuanJiNew_YueCuXiaoJinE").val());

            $("#FTradeReceivablesHuanJiNew_HeTongJinE").val(Price + GPSFeiYong + YueCuXiaoJinE);

        })
    })
    function validateCallbackFTradeReceivablesHuanJiNew(form, callback) {

        var $form = $(form);
        var $oldHeTongHao = "<%=obj.HeTongHao %>";
        var $newHeTongHao = $("#FTradeReceivablesHuanJiNew_HeTongHao").val();
        //var $table = $form.find("tbody.ODailyAdd");
        var $newXiaoShouLeiXing = $("#FTradeReceivablesHuanJiNewAdd_XiaoShouLeiXing").val();
        if ($newXiaoShouLeiXing == "请选择") {
            alertMsg.warn("请先选择一个 新的收款条款");
            return false;
        }
//        if ($oldHeTongHao == $newHeTongHao) {
//            alertMsg.warn("变更收款条款后，需要更改合同号");
//            $form.find("#FTradeReceivablesHuanJiNew_HeTongHao").focus();
//            return false;
//        }
        //新增时需要处理 金额是否与合同金额一致
        var $XiaoShouLeiXing = $("#FTradeReceivablesHuanJiNewAdd_XiaoShouLeiXing").val();
        var $HeTongJinE = $("#FTradeReceivablesHuanJiNew_HeTongJinE").val();
        var $inputPageJinE = 0;
        $("#FTradeReceivablesHuanJiNewAdd_ShowXXLSPage").find(":text[name='Page_JinE']").each(function () {
            $inputPageJinE = $inputPageJinE + parseFloat($(this).val());
        });
        if (parseFloat($HeTongJinE).toFixed(4) != parseFloat($inputPageJinE).toFixed(4)) {
            alertMsg.warn("合同金额与收款条款[" + $XiaoShouLeiXing + "]相应金额不一致,请检查更改后再提交.");
            return false;
        }
        //
        $("#FTradeReceivablesHuanJi_BtnSave").find("button").attr("disabled", "disabled").html("换机中......");
        setTimeout(function () { $("#FTradeReceivablesHuanJi_BtnSave").find("button").removeAttr("disabled").html(" 换 机 "); }, 20000);

        return validateCallback(form, callback);
    }
</script>
<div class="pageContent">
	<form  method="post" class="pageForm required-validate" action="FTradeModel/FTradeReceivablesHuanJi.aspx?ajaxmethod=add&FTradeID=<%=FTradeID %>" onsubmit="return validateCallbackFTradeReceivablesHuanJiNew(this, navTabAjaxDone);" >
		<div class="pageFormContent" layoutH="56">
            
            <h2 style=" padding:5px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">原换机信息 【<a href="FTradeModel/FTradeReceivablesView.aspx?FTradeID=<%=FTradeID %>" target="navTab" title="查看数据源" rel="FTradeReceivablesView" style=" font-weight:normal!important; color:Red;" >点击</a>】可查看原合同的详细信息</h2>
			    <p>
				<label>合 同 号：</label>
				<input name="HeTongHao_Fu" type="text" id="FTradeReceivablesHuanJi_HeTongHao" class="required" readonly value="<%=obj.HeTongHao %>" />
			    </p>
			    <p>
				    <label>原机换机时间：</label>
				    <input name="XiaoShouShiJian_Fu" class="required date" type="text" value=""  alt=""  />
			    </p>
			    <p>
				    <label>经 销 商：</label>
                    <input name="JingXiaoShang_Fu" type="text" value="<%=obj.JingXiaoShang %>"  class="required textInput "  readonly/>
			    </p>
                <p>
				    <label>营业经理：</label>
				    <input name="YingYeJingLi_Fu" class="required" type="text"  value="<%=obj.YingYeJingLi %>" alt="请输入营业经理" />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>型    号：</label>
                    <input name="XingHao_Fu" class="required" type="text"  value="<%=obj.XingHao %>" readonly/>
			    </p>
                <p>
				    <label>机    号：</label>
				    <input name="JiHao_Fu" class="required" type="text" size="" alt=""  value="<%=obj.JiHao %>" readonly />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>单    价：</label>
				    <input id="FTradeReceivablesHuanJi_Price" name="Price_Fu" class="required inputFloat" type="text" value="<%=obj.Price %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>GPS费 用：</label>
				    <input id="FTradeReceivablesHuanJi_GPSFeiYong" name="GPSFeiYong_Fu" class="required inputFloat" type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>月促销折让金额：</label>
                    <input id="FTradeReceivablesHuanJi_YueCuXiaoJinE" name="YueCuXiaoJinE_Fu" class="required inputFloat" type="text" value="<%=obj.YueCuXiaoJinE %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                 <p>
				        <label>GPS 号：</label>
				        <input name="" class="" type="text" value="<%=obj.GPSNum %>" size="" alt="" readonly/>
			        </p>
                <p>
				        <label>利息收入：</label>
				        <input  name="" class="" type="text" value="<%=obj.InterestIncome %>" size="" alt=""  readonly />
                        <span class="unit">元</span>
		        </p>
                <div class="divider"></div>
			    <p>
				    <label>合同金额：</label>
				    <input id="FTradeReceivablesHuanJi_HeTongJinE" name="HeTongJinE_Fu" class="required inputFloat" type="text"   value="<%=obj.HeTongJinE %>"  size="" alt=""/>
                    <span class="unit">元</span>
			    </p> 
                <p>
				<label>返还利息额：</label>
				<input  name="FanHuanLiXi_Fu" class="inputFloat" type="text" value="<%=obj.FanHuanLiXi %>"  readonly size="" alt=""/>
                <span class="unit">元</span>
			</p>              
                <div style="clear:both;"></div>            
				<label>合同付款条款：</label>
				<textarea name="FuKuanTiaoKuan_Fu" cols="80" rows="4"  ><%=obj.FuKuanTiaoKuan%></textarea>

            <div style="clear:both;"></div>
                <p>
			        <label>已收款项：</label>
			        <input name="YiShouKuanXiang" class="" type="text" readonly value="<%=obj.YiShouKuanXiang %>"　readonly />
		        </p>
                <p>
			        <label>未收款项：</label>
			        <input name="WeiShouKuanXiang" class="" type="text" readonly value="<%=obj.WeiShouKuanXiang %>"　readonly />
		        </p>
                <p>
			        <label>逾期款项：</label>
			        <input name="YuQiKuanXiang" class="" type="text" readonly value="<%=obj.YuQiKuanXiang %>"  alt=""/>
		        </p>
               <div style="clear:both;margin-bottom: 5px;"></div>

            <h2 style=" padding:5px 0px 5px 6px; border-bottom:1px solid #B8D0D6;">新机信息</h2>
		    
                <p>
				<label>合 同 号：</label>
				<input name="HeTongHao" type="text" id="FTradeReceivablesHuanJiNew_HeTongHao" class="required" value="<%=obj.HeTongHao %>" />
			    </p>
			    <p>
				    <label>换后新机销售时间：</label>
				    <input name="XiaoShouShiJian" class="required date" type="text" value=""  alt=""  />
			    </p>
			    <p>
				    <label>经 销 商：</label>
                    <input name="JingXiaoShang" type="text" value="<%=obj.JingXiaoShang %>"  class="required textInput autocomplete"   autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" swidth="300"/>
			    </p>
                <p>
				    <label>营业经理：</label>
				    <input name="YingYeJingLi" class="required" type="text"  value="<%=obj.YingYeJingLi %>" alt="请输入营业经理" />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>型    号：</label>
                    <%=GetMacType("select", "XingHao", obj.XingHao)%>
			    </p>
                <p>
				    <label>机    号：</label>
				    <input name="JiHao" class="required" type="text" size="" alt=""  value="<%=obj.JiHao %>" />
			    </p>
                <div class="divider"></div>
			    <p>
				    <label>单    价：</label>
				    <input id="FTradeReceivablesHuanJiNew_Price" name="Price" class="required inputFloat" type="text" value="<%=obj.Price %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>GPS费 用：</label>
				    <input id="FTradeReceivablesHuanJiNew_GPSFeiYong" name="GPSFeiYong" class="required inputFloat" type="text" value="<%=obj.GPSFeiYong %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				    <label>月促销折让金额：</label>
                   
                    <input id="FTradeReceivablesHuanJiNew_YueCuXiaoJinE" name="YueCuXiaoJinE" class="required inputFloat" type="text" value="<%=obj.YueCuXiaoJinE %>" size="" alt="" />
                    <span class="unit">元</span>
			    </p>
                <p>
				        <label>GPS 号：</label>
				        <input name="GPSNum" class="" type="text" value="<%=obj.GPSNum %>" size="" alt="" />
			        </p>
            <p>
				        <label>利息收入：</label>
				        <input  name="InterestIncome" class="required inputFloat" type="text" value="<%=obj.InterestIncome %>" size="" alt=""  />
                        <span class="unit">元</span>
		        </p>
                <div class="divider"></div>
			    <p>
				    <label>合同金额：</label>
				    <input id="FTradeReceivablesHuanJiNew_HeTongJinE" name="HeTongJinE" class="required inputFloat" type="text"   value="<%=obj.HeTongJinE %>"  size="" alt=""/>
                    <span class="unit">元</span>
			    </p>
                 <p>
				<label>返还利息额：</label>
				<input  name="FanHuanLiXi" class="inputFloat" type="text" value="<%=obj.FanHuanLiXi %>"   size="" alt=""/>
                <span class="unit">元</span>
			</p> 
                <p>
				    <label>到期日：</label>
				    <input name="DaoQiRi" class="" type="text" value="<%=obj.DaoQiRi %>" alt=""  />
			    </p>
                <div style="clear:both;"></div>
            
				<label>合同付款条款：</label>
				<textarea name="FuKuanTiaoKuan" cols="80" rows="4"  ><%=obj.FuKuanTiaoKuan%></textarea>
             

                <div style="clear:both;"></div>
               
                <label style=" color:Green; font-weight:bold;">新的收款条款：</label>
                <select id="FTradeReceivablesHuanJiNewAdd_XiaoShouLeiXing" name="XiaoShouLeiXing" class="required">
					<%=GetXiaoShouLeiXing(obj.XiaoShouLeiXing)%>
			    </select>
                <div id="FTradeReceivablesHuanJi_ShowSummary" style=" line-height:30px; color:Red; font-weight:bold;" >
                       
                </div>
                <div style="clear:both;"></div>
                <div id="FTradeReceivablesHuanJiNewAdd_ShowXXLSPage" style=" border:1px dotted #B8D0D6;  margin:5px 0px; ">
                    <%--显示显示销售对应的配置--%>
                </div>
                <script type="text/javascript">
                    $(document).ready(function () {

                        $("#FTradeReceivablesHuanJiNewAdd_XiaoShouLeiXing").change(function () {
                            changeXiaoShouLeiXingFTradeReceivablesHuanJiNewAdd($(this).val());
                        })
                        function changeXiaoShouLeiXingFTradeReceivablesHuanJiNewAdd(key) {
                            key = encodeURI(key);
                            var url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?tag=huanji&key=" + key
                            $("#FTradeReceivablesHuanJiNewAdd_ShowXXLSPage").loadUrl(url);
                            //
                            url = "FTradeModel/GetPageFTradeSaleTypeConfig.aspx?ajaxmethod=getconfigsummary&key=" + key
                            $("#FTradeReceivablesHuanJi_ShowSummary").loadUrl(url);
                        }


                        changeXiaoShouLeiXingFTradeReceivablesHuanJiNewAdd('<%=obj.XiaoShouLeiXing %>');
                    })
                </script>

                <div style="clear:both;margin-bottom: 5px;"></div>   
                
        </div>
		<div class="formBar">
			<ul>
				
				<li ><div id="FTradeReceivablesHuanJi_BtnSave" class="buttonActive"><div class="buttonContent"><button type="submit"  >换机</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>